﻿package com.hxh.ocean.view{

	import com.hxh.ocean.events.*;
	import com.hxh.ocean.helpers.*;
	import com.hxh.utils.*;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.filters.*;

	public class BubbleButton extends Bubble {

		private var _highlighted:Boolean;
		
		public function BubbleButton(bubbleName:String, sprite:MovieClip) {
			super(bubbleName, sprite);
			_highlighted = false;
		}

		public function get Label():String{
			return _label.movLabel.txtLabel.text;
		}
		
		public function set Label(label:String):void{
			_label.movLabel.txtLabel.text = label;
		}
		
		public function get Highlighted():Boolean
		{
			return _highlighted;
		}

		public function set Highlighted(v:Boolean):void
		{
			_highlighted = v;
			if (_highlighted){
				var buttonFx:GlowFilter = new GlowFilter(0xFFFFFF, 1, 2, 2, 3, BitmapFilterQuality.HIGH);
				Common.addFilter(BaseSprite, buttonFx);
			}
			else{
				Common.removeFilter(BaseSprite);
			}
		}

		public function setHighlighted():void{
			_highlighted = !_highlighted;
			if (_highlighted){
				var buttonFx:GlowFilter = new GlowFilter(0xFFFFFF, 1, 2, 2, 3, BitmapFilterQuality.HIGH);
				Common.addFilter(BaseSprite, buttonFx);
			}
			else{
				Common.removeFilter(BaseSprite);
			}
		}
			
		protected override function doUpdate():void{
			//Empty out because the button wont move anywhere, dont need to update self
		}

		protected override function buildAppearance(bubbleName:String, sprite:MovieClip):void {
			super.buildAppearance(bubbleName, sprite);
			_label = new BubbleButtonLabel();
			_label.setLabel(bubbleName); 
			_label.addEventListener(Events.LABEL_FINISH, removeLabel);
		}
	}
}